function HeGroupAddController(
    params,
    HeGroup,
    RobotGroup,
    $state,
    $rootScope,
    $uibModal
){
    var vm=this;
    vm.resultMsg;
    vm.scope = $rootScope.$new();
    vm.isSame = true;
    vm.serverError = false;
    vm.showErr = false;

    var params = params;
    if(params == null){

    }else{
        RobotGroup.detail({groupId:params}).$promise.then(function(response){
            vm.robotGroupDetail=response.result;
            if(vm.robotGroupDetail == null){
                vm.resultMsg = "未查询到分组信息";
                vm.scope.data = {
                    msg:vm.resultMsg
                }
                var tipsModel = $uibModal.open({
                    templateUrl: 'tipsModel.html',
                    controller: 'groupTipsCtrl',
                    scope:vm.scope
                });
            }else{
                vm.groupId = vm.robotGroupDetail.groupId;
                vm.groupName = vm.robotGroupDetail.groupName;
                vm.currentGroupName = vm.robotGroupDetail.groupName;
            }
        })
    }


    //监听分组名称input 防止多次修改相同名称
    vm.nameChange = function(){
        if(vm.groupName == vm.currentGroupName || vm.currentGroupName == undefined || vm.currentGroupName == ''){
            vm.isSame = true;
        }else{
            vm.isSame = false;
        }
        vm.showErr = false;
    }


    vm.add=function(){
        HeGroup.createNewGroup({groupId:vm.groupId, groupName:vm.currentGroupName}).$promise.then(function(response){
            vm.isSame = true;
            if(response.result == "1"){
                if(params == null){
                    $state.go('addRobotInGroup', {groupId:response.groupId});
                }else{
                    $state.go('groupList');
                }
            }else{
                if(response.msg != ''){
                    vm.serverError = response.msg;
                    vm.resultMsg = response.msg;
                }else{
                    vm.serverError = "异常，请稍后再试！";
                    vm.resultMsg = "异常，请稍后再试！";
                }
                vm.showErr = true;
            }
            vm.isSame = false;
        })
    }
    vm.cancel = function() {
        $state.go('groupList');
    }
}